#include "MySQLConnection.h"

namespace SQLDoc
{
	const QString MySQLConnection::SELECT_DATABASES_QUERY("show databases");

	MySQLConnection::MySQLConnection(void)
		: DBConnection()
	{ }

	MySQLConnection::~MySQLConnection(void)
	{ }

	void MySQLConnection::fillDatabases()
	{
		DBConnection::fillDatabases();

		QSqlDatabase db = QSqlDatabase::database(this->connectionName());

		QSqlQuery query(db);
		query.setForwardOnly(true);
		query.exec(SELECT_DATABASES_QUERY);

		while (query.next())
		{
			MySQLDb* t = new MySQLDb();
			t->setName(query.value(0).toString());
			m_databases.append(t);
		}
	}
}
